package com.bw.classfiy.mvvm.bind;

import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;

import androidx.databinding.BindingAdapter;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

import com.bw.classfiy.R;
import com.bw.classfiy.mvvm.adapter.ClassFiyBannerAdapter;
import com.bw.classfiy.mvvm.adapter.ClassFiyTableAdapter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.youth.banner.Banner;

import java.util.List;

import javax.crypto.spec.RC2ParameterSpec;

public class ClassFiyBind {

    @BindingAdapter(value = "classfiyleft")
    public static void bindClassFiyTableRcBind(RecyclerView recyclerView,
                                        BaseQuickAdapter baseQuickAdapter) {
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(recyclerView.getContext());
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(linearLayoutManager);
        recyclerView.setAdapter(baseQuickAdapter);

    }
    @BindingAdapter(value = {"classfiyrigth","banner"})
    public static void bindClassFiyAdapterBanner(RecyclerView recyclerView,
                                                 BaseQuickAdapter baseQuickAdapter,
                                                 List<String> imag
                                                 ){
        StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(3,StaggeredGridLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(staggeredGridLayoutManager);
        View view = LayoutInflater.from(recyclerView.getContext()).inflate(R.layout.classfiy_banner,null);
        Banner banner = view.findViewById(R.id.classfiy_banner);
        ClassFiyBannerAdapter bannerAdapter = new ClassFiyBannerAdapter(imag);
        banner.setAdapter(bannerAdapter)
                .setOrientation(Banner.HORIZONTAL)
                .start();
        baseQuickAdapter.addHeaderView(view);
        recyclerView.setAdapter(baseQuickAdapter);

    }
}
